<?php
/**
 * Created by PhpStorm.
 * User: W
 * Date: 2019/1/14
 * Time: 14:42
 */

namespace app\sports_admin\model;


use think\Model;
use think\Request;

class Test extends Model
{
    protected $table = "test";
    protected $pk    = "id";
    protected $autoWriteTimestamp = true;
    /**
     * 测试类型 列表
     * @param $page 页数
     * @param $rows 行数
     * @param $sort 排序字段
     * @param $sortOrder 升降序
     * @return array
     */
    public static function testList($page,$rows,$sort,$sortOrder)
    {
        $adminList = self::
        page($page)
            ->limit($rows)
            ->order("{$sort}","{$sortOrder}")
            ->select();
        $adminCount = self::count();
        return ['rows'=>$adminList,'total'=>$adminCount];
    }
    //测试类型 删除
    public static function del()
    {
        $id = Request::instance()->only('id');
        return self::where('id',$id['id'])->delete();
    }
    //测试类型 添加
    public static function add()
    {
        $data = Request::instance()->only('test_name');
        return self::create($data);
    }

}